
<!DOCTYPE html>
<html lang="en"; xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>巡检任务的制定与分配</title>
    <link rel="stylesheet" href="/static/component/pear/css/pear.css">
    <link rel="stylesheet" href="/webjars/layui/2.5.5/css/layui.css"  media="all">
    <style>
        *{margin: 0px auto;
            padding: 0px;
        }
        .q:after{
            content:'';
            display: block;
            clear: both;
        }
        .layui-table-cell{
            height: 30px;
        }
        .message li{
            float:  left;
            font-size: 16px;
            margin-right: 30px;
        }
        .message li span{
            margin-left: 4px;
        }
        .message ul{
            margin-top: 20px;
        }
        .message ul span{
            color: gray;
        }
        .XianLuXinXi{

        }
        .XianLuXinXi ul{

        }
        .XianLuXinXi li{
            float: left;
            font-size: 16px;
            margin-top: 20px;
            margin-left: 100px;
        }
    </style>
</head>
<body>

<!--查询条件-->
<form class="layui-form" action="">
    <div class="layui-form-item" style="margin-top: 50px">
        <div class="layui-inline">
            <label class="layui-form-label">任务编号:</label>
            <div class="layui-input-inline">
                <input type="text" name="solveTaskCode" id="RenWuBiAnHao" lay-verify="title" autocomplete="off" placeholder="请输入任务编号" class="layui-input">
            </div>
            <label class="layui-form-label">任务名称：</label>
            <div class="layui-input-inline">
                <input type="text" name="solveTaskName" id="solveTaskName" lay-verify="title" autocomplete="off" placeholder="请输入线路编号" class="layui-input">
            </div>
            <label class="layui-form-label">任务状态:</label>
            <div class="layui-input-inline">
                <select name="taskStatus" lay-verify="" id="dp" class="service3">
                    <option value="0">请选择</option>
                </select>
            </div>
            <div class="layui-input-inline">
                <button type="button" class="layui-btn layui-btn-normal zengJiQxMessage" id="zengJia" onclick="addXunJian()"><i class="layui-icon">&#xe608;</i>制定消缺任务</button>
            </div>
        </div>
        <div class="layui-inline" style="margin-top: 20px">
            <label class="layui-form-label">*下发人:</label>
            <div class="layui-input-inline">
                <input type="text" name="issuedByName" id="xiaFaRen" lay-verify="title" autocomplete="off" placeholder="请输入任务编号" class="layui-input">
            </div>
            <label class="layui-form-label">下放时间：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input"  name="kai"  placeholder="" id="kaishi">
            </div>
            <label class="layui-form-label">时间结束:</label>
            <div class="layui-input-inline">
                <input type="text" name="jie"  class="layui-input"  placeholder="" id="jeiShu">
            </div>
            <div class="layui-input-inline">
                <button type="submit" class="layui-btn layui-btn-normal zengJiQxMessage" lay-submit  lay-filter="user-query">
                    查询
                </button>
            </div>
        </div>
    </div>
</form>
<!--表格-->
<!--<div class="layui-container " id="tableid" style="width: 100%" >-->
<!--    <table class="" id="test" lay-filter="test" style="margin-top:50px;"></table>-->
<!--</div>-->
<div class="layui-card">
    <div class="layui-card-body">
        <table id="user-table" lay-filter="user-table"></table>
    </div>
</div>
<!--操作块代码-->
<script type="text/html" id="active">
    <div class="layui-input-block" style="margin-left: 0px">
        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm"  lay-event="ChaKan" >查看</button>
        {{#  if(d.taskStatusName == "待分配"){  }}
         <button type="button" class="layui-btn layui-btn-primary layui-btn-sm"  lay-event="FenPeiRenWu">分配任务</button>
        {{# }else{ }}
        <button type="button" class="layui-btn layui-btn-normal layui-btn-sm layui-btn-disabled" disabled lay-event="FenPeiRenWu">分配任务</button>
        {{# } }}
        {{# if(d.taskStatusName == "已完成"){  }}
           <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="shenCha" >审查</button>
        {{# }else if(d.taskStatusName == "待分配"){ }}
           <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="xiuGai">修改</button>
        {{# }else{ }}
            <button type="button" class="layui-btn layui-btn-normal layui-btn-sm layui-btn-disabled" disabled lay-event="xiuGai">修改</button>
        {{# } }}
        {{#  if(d.taskStatusName == "待分配"){  }}
        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm  "  lay-event="quXiao">取消</button>
        {{# }else{ }}
        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm  layui-btn-disabled" disabled lay-event="quXiao">取消</button>
        {{# } }}
    </div>
    <!--回执-->
</script>
<script type="text/html" id="active2">
    <div class="layui-input-block" style="margin-left: 0px">
        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm"  lay-event="yiCHu">移除</button>
    </div>
    <!--回执-->
</script>
<!--js文件-->
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<!--<script type="text/javascript" src="/static/component/layui/dtree.js"></script>-->

<script type="text/javascript">
    //数据初始化
    layui.use(["jquery","layer","form","table","laydate"],function () {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let drawer = layui.drawer;
        let dropdown = layui.dropdown;
        let laydate=layui.laydate;
        let MODULE_PATH = "/system/user/";
        laydate.render({
            elem: '#kaishi'
        });
        laydate.render({
            elem: '#jeiShu'
        });
        // cols 格式
        let cols = [
            [
                {
                    title: 'id',
                    field: 'id',
                    align: 'center',
                    width: 100
                },
                {
                    title: '任务编号',
                    field: 'solveTaskCode',
                    align: 'center',
                    width: 100
                },
                {
                    title: '任务名称',
                    field: 'solveTaskName',
                    align: 'center',
                    width: 100
                },
                {   title: '工作单据',
                    field: 'workDocTypeName',
                    align: 'center'
                },
                {   title: '下发人',
                    field: 'issuedByName',
                    align: 'center',
                    width: 80,
                },
                {   title: '下发时间',
                    field: 'issuedTime',
                    align: 'center'
                },
                {   title: '任务状态',
                    field: 'taskStatusName',
                    align: 'center'
                },
                {   title: '任务完成时间',
                    field: 'finishTime',
                    align: 'center'
                   ,templet: function(d){
                   return d.finishTime=" "?"———":d.finishTime;
                }},

                {   title: '任务是否取消',
                    field: 'isCancel',
                    align: 'center',
                    width: 170,
                    templet: function(d){
                        return d.finishTime="0"?"否":"是";
                }},
                {   title: '操作',
                    toolbar: '#active',
                    align: 'center',
                    width: 300
                }
            ]
        ]
        table.render({
            elem:'#user-table',
            url:'/XiaoQueHuiZhi/ChaRenBianZiShu1',
            page: true,
            cols: cols,
            skin: 'line',
            toolbar: '#user-toolbar',
            defaultToolbar: [{
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter', 'print', 'exports'],
            page:{
                limit:3,
                limits:[3,6,9]
            }
        });
        $.ajax({
            url:"/XiaoQueHuiZhi/chaRenWuZhuangTai",
            dataType: 'json',
            success: function(data) {
                if (data!== null) {
                    $(".service3").empty();
                    $(".service3").append(new Option("--请选择--","0"));
                    $.each(data, function(index, item) {
                        $('.service3').append(new Option(item.configName,item.id));
                    });
                } else {
                    $(".service3").append(new Option("暂无数据","0"));
                }
                //重新渲染
                form.render("select");
            }
        })
        //表格监听
        table.on("tool(user-table)",function ({data,event}) {
            switch (event) {
                case "ChaKan":
                    // alert("查看");
                    chaKan(data);
                    break;
                case "FenPeiRenWu":
                    FenPeiRenWu(data.id,data.ZhuAngTai)
                    break;
                case "shenCha":

                    break;
                case "xiuGai":
                    update(data);
                    break;
                case "quXiao":
                    break;
            }
        })
        table.on("tool(user-table5)",function (obj) {
            var data =obj.data;
            var event=obj.event;
            switch (event) {
                case "yiCHu":
                    alert("ke")
                    layer.confirm('真的删除行么', function(index){
                        //删除
                        $.ajax({
                            url:'/XunJiAnRenWu/ShanChuZiBiao',
                            dataType:'json',
                            data:{"id":data.id},
                            type:'get',
                            success:function(data){
                                if(data){
                                    console.log("删除成功了额");
                                    table.reload("user-table5");
                                }else {
                                    console.log("删除失败了额");
                                }

                            }
                        });
                        layer.close(index);
                    });
                    break;
            }
        })
        //表单监听
        form.on('submit(user-query)', function(data) {
            console.log(data.field)
            table.reload('user-table', {
                where: data.field
            })
            return false;
        });
    });

    //查看
    function chaKan(k) {
        layui.use(["jquery","layer","form","table",'transfer','util','popup','dtree'],function (){
            let layer=layui.layer;
            let $=layui.$;
            let table=layui.table;
            let popup = layui.popup;
            let transfer = layui.transfer;
            let form =layui.form;
            let dtree=layui.dtree;
            let cols1 = [
                [
                    {
                        title: '线路编号',
                        field: 'lineCode',
                        align: 'center',
                    },
                    {
                        title: '杆塔编号',
                        field: 'poleCode',
                        align: 'center',
                    },
                    {   title: '缺陷等级',
                        field: 'bugLevelName',
                        align: 'center'
                    },
                    {   title: '缺陷类型',
                        field: 'bugTypeName',
                        align: 'center',
                    },
                    {   title: '缺陷描述',
                        field: 'bugDesc',
                        align: 'center'
                    },
                    {   title: '发现人',
                        field: 'discovererName',
                        align: 'center'
                    },
                    {   title: '发现时间',
                        field: 'discoverTime',
                        align: 'center'
                    }
                ]
            ]
            layer.open({
                type:1,
                title:"查看信息",
                area:["930px","800px"],
                // btn:["上传回执","保存","取消"],
                content:$("#Cha"),
                success: function(layero, index){
                    table.render({
                        elem:'#user-table4',
                        url:'/XiaoQuGuanLi/XiaoQuAnNanNiuChKanXiaoQuRenWU?id='+k.id,
                        page: true,
                        cols: cols1,
                        skin:'line',
                        // data:datas,
                        page:{
                            limit:3,
                            limits:[3,6,9]
                        }
                    });
                    var mycars = new Array()
                    //查看按钮表单赋值
                    $.ajax({
                        type:'post',
                        dataType: "json",
                        contentType: 'application/json;charset=utf-8',
                        url:"/XiaoQuGuanLi/chaXunJianYuanChanKanGongNeng?id="+k.id,
                        success:function(c) {
                            // console.log(c.+"的值")
                            $.each(c,function (index,val) {
                                mycars.push(val.solverName);
                            });
                            $(".xiaoQuYuan").val(mycars.join(","));
                        },
                    });
                    layui.form.val("ChaForm",k);

                }
            })
        });
    };

    //分配任务
    function  FenPeiRenWu(id,ZhuAngTai) {
        // alert("分配任务")
        layui.use(["jquery","layer","form","table",'transfer','util','popup'],function () {
            let layer=layui.layer;
            let $=layui.$;
            let table=layui.table;
            let popup = layui.popup
                ,transfer = layui.transfer
            $.post("/XiaoQuGuanLi/ChaChuAnSuoKuang",function(c){
                transfer.render({
                    elem:'#FenPeiRenWu'
                    ,data:c
                    ,width:150 //定义宽度
                    ,height:210 //定义高度
                    ,title:['待选巡检员', '已选巡检员']
                    ,id: 'key123' //定义唯一索引
                })
            })
            layer.open({
                type:1,
                content:$("#FenPeiRenWu"),//divID
                area:["500px","350px"],
                btn:["确定","取消"],
                title:"分配巡检",
                yes(){
                    let getData = transfer.getData('key123'); //获取右侧数据
                    let aa=JSON.stringify(getData);
                    // alert(aa+id);
                    $.ajax({
                        type:'POST',
                        dataType: "json",
                        contentType: 'application/json;charset=utf-8',
                        url:"/XiaoQuGuanLi/xiaoQueRenWuFenPei?id="+id,
                        data:aa,
                        success:function (c) {
                            if(c){
                                layer.close(layer.index);
                                popup.success("分配成功")
                                // table.reload("test")
                                table.reload("user-table");
                            }else {
                                layer.close(layer.index);
                                popup.success("分配失败")
                            }
                        },
                    });
                },
            });
            //layui  结束标签
        })
    };

    //修改
    function  update(dt) {
        //第一步  打开 弹框
        layui.use(["jquery","layer","form","table",'transfer','util','popup'],function (){
            let layer=layui.layer;
            let $=layui.$;
            let table=layui.table;
            let popup = layui.popup;
            let transfer = layui.transfer;
            let form=layui.form;
            layer.open({
                type:1,
                content:$("#updateDate"),//divID
                area:["800px","752px"],
                btn:["确定","取消"],
                title:"修改消缺信息",
                yes(){
                    if(table.checkStatus("user-table5").data==null||table.checkStatus("user-table5").data==""){
                        alert("未添加缺陷信息--请先添加缺陷信息")
                        return;
                    }
                    let parms=layui.form.val("updateDate");  //拿到表单元素
                    //获取add巡检信息
                    let addXunJIanYuan="";
                    if($("#xiaoQuYuan").val()!=""){
                        addXunJIanYuan=layui.transfer.getData('keyZeng'); //获取右侧数据
                    }else {
                        addXunJIanYuan=null;
                    }
                    FengZhuangDeZongShuJu.psSolvetaskMain=parms;
                    FengZhuangDeZongShuJu.psSolverDetail=addXunJIanYuan;
                    FengZhuangDeZongShuJu.psSolvetaskDetail= table.checkStatus("user-table5").data;
                    //这个有个问题
                    let xi=JSON.stringify(FengZhuangDeZongShuJu);
                    console.log(xi+"aaaaaa");
                    $.ajax({
                        type:'POST',
                        dataType:"json",
                        contentType:'application/json;charset=utf-8',
                        url:"/XunJiAnRenWu/XiaoQuMessageXiuGai?id="+dt.id,
                        data:xi,
                        success:function (c) {
                            console.log(c);
                            if(c){
                                // layer.closeAll(layer.index);
                                popup.success("修改成功");
                                arr1=[];
                                table.reload("user-table");
                            }else {
                                popup.success("增加失败")
                            }
                            layer.closeAll('page'); //关闭所有页面层
                        },
                    });
                },success: function(layero, index){
                    let danju=$('#gongzuoDanJu1').children().length;
                    let RenWuFuZeRen=$('#RenWuFuZeRen1').children().length;
                    //查询任务负责人
                    //巡检员赋值  得到当前任务id  去巡检明细表里查找
                    //第一个下拉框工作单据
                    if(danju==1){
                        $.ajax({
                            url:'/XiaoQueHuiZhi/DanJuLeiXIng',
                            dataType:'json',
                            type: 'get',
                            async: false,
                            success:function(data){
                                $.each(data,function (index,value) {
                                    $('#gongzuoDanJu1').append(new Option(value.configName,value.id));// 下拉菜单里添加元素
                                });
                                form.render("select");//重新渲染 固定写法
                                //查询
                            }
                        })
                    }
                    // //弹框打开之前赋值 负责人
                    if(RenWuFuZeRen==1){
                        $.ajax({
                            url:'/XiaoQuGuanLi/xiaoQuYuan',
                            dataType:'json',
                            type: 'get',
                            async: false,
                            success:function(data){
                                $.each(data,function (index,value) {
                                    $('#RenWuFuZeRen1').append(new Option(value.userName,value.id));// 下拉菜单里添加元素
                                });
                               form.render("select");//重新渲染 固定写法
                            }
                        })
                    }
                    $('#RenWuFuZeRen1').val(dt.taskManagerName);
                    let  xiuGaiXUnJianYuanShuZU=[];
                    $.ajax({
                        url:'/XunJiAnRenWu/ChaXunJianYuan',
                        dataType:'json',
                        data:{"id":dt.id},
                        type:'get',
                        async: false,
                        success:function(data){
                            $.each(data,function (index,value) {
                                xiuGaiXUnJianYuanShuZU.push(value.inspectorName);
                            });
                            let  fenGeShuJu= xiuGaiXUnJianYuanShuZU.join(",");
                            $(".xunJiAnYuan").val(fenGeShuJu);
                            //从新赋值  穿梭框
                           form.render("select");//重新渲染 固定写法
                            //查询
                        }
                    });
                    let  fuZeRen="";
                    $.ajax({
                        url:'/XiaoQuGuanLi/chaMouGeFuZeRen',
                        dataType:'json',
                        data:{"id":dt.taskManagerCode},
                        type:'POST',
                        async: false,
                        success:function(a){
                            fuZeRen=a.id;
                            form.render("select");//重新渲染 固定写法
                        }
                    });
                    let cols1 = [
                        [
                            {
                              type:"checkbox"
                            },
                            {
                                title: '线路编号',
                                field: 'lineCode',
                                align: 'center',
                            },
                            {
                                title: '杆塔编号',
                                field: 'poleCode',
                                align: 'center',
                            },
                            {   title: '缺陷等级',
                                field: 'bugLevelName',
                                align: 'center'
                            },
                            {   title: '缺陷类型',
                                field: 'bugTypeName',
                                align: 'center',
                            },
                            {   title: '缺陷描述',
                                field: 'bugDesc',
                                align: 'center'
                            },
                            {   title: '发现人',
                                field: 'discovererName',
                                align: 'center'
                            },
                            {   title: '发现时间',
                                field: 'discoverTime',
                                align: 'center'
                            },
                            {   title: '操作',
                                toolbar: '#active2',
                                align: 'center',
                            }
                        ]
                    ]
                    table.render({
                        elem:'#user-table5',
                        id:"user-table5",
                        url:'/XiaoQuGuanLi/XiaoQuAnNanNiuChKanXiaoQuRenWU?id='+dt.id,
                        page: true,
                        cols: cols1,
                        skin:'line',
                        page:{
                            limit:3,
                            limits:[3,6,9]
                        }
                    });
                    layui.use(['form'],() => {
                        let form = layui.form
                        form.val("updateDate",dt);
                        $("#gongzuoDanJu1").val(dt.workDocType)
                        $("#RenWuFuZeRen1").val(fuZeRen)
                        form.render("select");//重新渲染 固定写法
                    });
                }
            });
            //结束标签
        });
    };
    //删除
    function  del(id) {
        // layui.use(["jquery","layer","form","table"],function () {
        //     let layer=layui.layer;
        //     let $=layui.$;
        //     let table=layui.table;
        //     let popup = layui.popup;
        //     $.post("/XunJiAnRenWu/QuXiAoXunJiAn",{id:id},function (c){
        //         if(c.msg=="取消成功"){
        //             layer.msg("取消成功", {icon: 6});
        //             table.reload("test",{
        //                 page:{
        //                     curr: 1 //重新从第 1 页开始
        //                 }
        //             })
        //         }else {
        //             layer.msg("取消失败", {icon: 5});
        //         }
        //     });
        // });
    };
    //添加缺陷
    layui.use(["jquery","layer","form","table","laydate"],function () {
            let table = layui.table;
            let form = layui.form;
            let $ = layui.jquery;
            let drawer = layui.drawer;
            let dropdown = layui.dropdown;
            let laydate=layui.laydate;
            let layer=layui.layer;
            //==================================================================添加巡检项目
            $(".TianJiaQuXian").click(function () {
                //先查询缺陷信息在打开 弹窗
                let cols = [
                    [
                        {
                            type: 'checkbox'
                        },
                        {
                            title: '线路编号',
                            field: 'lineCode',
                            align: 'center',
                        },
                        {
                            title: '杆塔编号',
                            field: 'poleCode',
                            align: 'center',
                        },
                        {   title: '缺陷等级',
                            field: 'bugLevelName',
                            align: 'center'
                        },
                        {   title: '缺陷类型',
                            field: 'bugTypeName',
                            align: 'center',
                        },
                        {   title: '缺陷描述',
                            field: 'bugDesc',
                        },
                        {   title: '发现人',
                            field: 'discovererName',
                            align: 'center'
                        },
                        {   title: '发现时间',
                            field: 'discoverTime',
                            align: 'center'
                        }
                    ]
                ]
                let cols1 = [
                    [
                        {
                            type: 'checkbox'
                        },
                        {
                            title: '线路编号',
                            field: 'lineCode',
                            align: 'center',

                        },
                        {
                            title: '杆塔编号',
                            field: 'poleCode',
                            align: 'center',

                        },
                        {   title: '缺陷等级',
                            field: 'bugLevelName',
                            align: 'center'
                        },
                        {   title: '缺陷类型',
                            field: 'bugTypeName',
                            align: 'center',
                        },
                        {   title: '缺陷描述',
                            field: 'bugDesc',
                            align: 'center'
                        },
                        {   title: '发现人',
                            field: 'discovererName',
                            align: 'center'
                        },
                        {   title: '发现时间',
                            field: 'discoverTime',
                            align: 'center'
                        }
                    ]
                ]
                //最上级 table
                table.render({
                    elem:'#user-table2',
                    url:'/XiaoQueHuiZhi/ChaXunJianZiRenWUQuXianXinXi',
                    // url:'',
                    page: true,
                    cols: cols,
                    skin: 'line',
                    defaultToolbar: [{
                        layEvent: 'refresh',
                        icon: 'layui-icon-refresh',
                    }, 'filter', 'print', 'exports'],
                    page:{
                        limit:3,
                        limits:[3,6,9]
                    }
                });
                let  datas=null;
                layer.open({
                            type:1,
                            content:$("#addmk2"),//divID
                            area:["800px","500px"],
                            btn:["确定","取消"],
                            title:"选择缺陷信息",
                            yes(){
                                layer.close(layer.index);
                                //表格二初始化  拿到表格2 选中的数据
                                datas =table.checkStatus("user-table2").data
                                //赋值给表格三
                                table.render({
                                    elem:'#user-table3',
                                    page: true,
                                    cols: cols1,
                                    skin:'line',
                                    defaultToolbar: [{
                                        layEvent: 'refresh',
                                        icon: 'layui-icon-refresh',
                                    }, 'filter', 'print', 'exports'],
                                    data:datas,
                                    page:{
                                        limit:3,
                                        limits:[3,6,9]
                                    }
                                });
                                //赋值给表格五
                                table.render({
                                    elem:'#user-table5',
                                    page: true,
                                    cols: cols1,
                                    skin:'line',
                                    data:datas,
                                    defaultToolbar: [{
                                        layEvent: 'refresh',
                                        icon: 'layui-icon-refresh',
                                    }, 'filter', 'print', 'exports'],
                                    page:{
                                        limit:3,
                                        limits:[3,6,9]
                                    }
                                });
                            },
                });
            })

        });
    //穿梭框数据 巡检员 表单值
    let arr1=[];
    //返回后台的数据对象
    let FengZhuangDeZongShuJu=new Object();
    //添加巡检
    function  addXunJian() {
        //第一步  打开 弹框
        layui.use(["jquery","layer","form","table",'transfer','util','popup'],function (){
            let layer=layui.layer;
            let $=layui.$;
            let table=layui.table;
            let popup = layui.popup;
            let transfer = layui.transfer;
            let cols = [
                [
                    {
                        title: '线路编号',
                        field: 'lineCode',
                        align: 'center',
                    },
                    {
                        title: '杆塔编号',
                        field: 'poleCode',
                        align: 'center',
                    },
                    {   title: '缺陷等级',
                        field: 'bugLevelName',
                        align: 'center'
                    },
                    {   title: '缺陷类型',
                        field: 'bugTypeName',
                        align: 'center',
                    },
                    {   title: '缺陷描述',
                        field: 'bugDesc',
                        align: 'center'
                    },
                    {   title: '发现人',
                        field: 'discovererName',
                        align: 'center'
                    },
                    {   title: '发现时间',
                        field: 'discoverTime',
                        align: 'center'
                    }
                ]
            ]
            table.render({
                elem:'#user-table3',
                page: true,
                cols: cols,
                skin:'line',
                data:[
                ],
                page:{
                    limit:3,
                    limits:[3,6,9]
                }
            });
            //消缺员内容清空
            $(".xunJiAnYuan").val("");
            //下拉框赋值长度
            let danju=$('#gongzuoDanJu').children().length;
            // RenWuFuZeRen
            let RenWuFuZeRen=$('#RenWuFuZeRen').children().length;
            $("#addmk>form")[0].reset();
            //第一个下拉框工作单据
            if(danju==1){
                $.ajax({
                    url:'/XiaoQueHuiZhi/DanJuLeiXIng',
                    dataType:'json',
                    type: 'get',
                    success:function(data){
                        $.each(data,function (index,value) {
                            $('#gongzuoDanJu').append(new Option(value.configName,value.id));// 下拉菜单里添加元素
                        });
                        layui.form.render("select");//重新渲染 固定写法
                        //查询
                    }
                })
            }
            //弹框打开之前赋值 负责人
            if(RenWuFuZeRen==1){
                $.ajax({
                    url:'/XiaoQuGuanLi/xiaoQuYuan',
                    dataType:'json',
                    type: 'get',
                    success:function(data){
                        $.each(data,function (index,value) {
                            $('#RenWuFuZeRen').append(new Option(value.userName,value.id));// 下拉菜单里添加元素
                        });
                        layui.form.render("select");//重新渲染 固定写法
                    }
                })
            }
            layer.open({
                type:1,
                content:$("#addmk"),//divID
                area:["1000px","620px"],
                btn:["确定","取消"],
                title:"制定消缺任务",
                yes(){
                    if(table.checkStatus("user-table3").data==null||table.checkStatus("user-table3").data==""){
                        alert("未添加缺陷信息--请先添加缺陷信息")
                        return;
                    }
                    //插入数据赋值
                    //获取add巡检信息
                    let parms=layui.form.val("addform");  //拿到表单元素
                    let addXunJIanYuan="";
                    if($(".xunJiAnYuan").val()!=""){
                        addXunJIanYuan=layui.transfer.getData('keyZeng'); //获取右侧数据
                    }else {
                        addXunJIanYuan=null;
                    }
                    //最外围是个对象
                    //第二层是个对象属性
                    FengZhuangDeZongShuJu.psSolvetaskMain=parms;
                    FengZhuangDeZongShuJu.psSolverDetail=addXunJIanYuan;
                    FengZhuangDeZongShuJu.psSolvetaskDetail=table.checkStatus("user-table3").data;
                    console.log(JSON.stringify(FengZhuangDeZongShuJu))
                    let xi=JSON.stringify(FengZhuangDeZongShuJu);

                    $.ajax({
                        type:'POST',
                        dataType:"json",
                        contentType:'application/json;charset=utf-8',
                        url:"/XiaoQuGuanLi/AddXiaoQuRenWu",
                        data:xi,
                        success:function (c) {
                            if(c.msg=="添加消缺信息成功"){
                                // layer.closeAll(layer.index);
                                popup.success("增加成功");
                                arr1=[];
                                table.reload("user-table");
                            }else {
                                popup.success("增加失败")
                            }
                            layer.closeAll('page'); //关闭所有页面层
                        },
                    });
                },success:function () {
                    //1.给任务 名称   任务单号 赋值
                    layui.config({
                        base: '../static/component/pear/modules/' //配置 layui 第三方扩展组件存放的基础目录
                    }).extend({
                        pinyin:'pinyin' //以 regionSelect 组件为例，定义该组件模块名
                    }).use(['pinyin'], function () {
                        let pinyin =layui.pinyin;
                        // let ce=data.elem[data.elem.selectedIndex].text;
                        //console.log(pinyin.ConvertPinyin(ce));    //mihuchong
                        //console.log(pinyin.makePy(ce));   //["MHC"]
                        let outTradeNo="";  //订单号
                        for(let i=0;i<4;i++) //6位随机数，用以加在时间戳后面。
                        {
                            outTradeNo += Math.floor(Math.random()*10);
                        }
                        // outTradeNo = new Date().getTime() + outTradeNo;  //时间戳，用来生成订单号。
                        let rwn="任务"
                        let shuZU = pinyin.makePy(rwn);
                        $("#RenWuMingCheng").val("消缺"+shuZU[0]+outTradeNo);
                        $("#RenWUBiAnMa").val(shuZU[0]+outTradeNo);
                    });
                    //查询
                }
            });
            //结束标签
        });
    };
    //获得光标 显示穿梭框
    layui.use(["jquery","layer","form","table",'transfer','util','popup'],function (){
        let layer=layui.layer;
        let $=layui.$;
        let table=layui.table;
        let popup = layui.popup;
        let transfer = layui.transfer;
        let form =layui.form;
        $(".xunJiAnYuan").focus(function (){
            let arrJson=JSON.stringify(arr1);
            //赋值穿梭框
            if($(".xunJiAnYuan").val()==""){
                $.post("/XiaoQuGuanLi/ChaChuAnSuoKuang",function(c){
                    transfer.render({
                        elem:'#ZeNgJiaChuAnSUo'
                        ,data:c
                        ,width:150 //定义宽度
                        ,height:210 //定义高度
                        ,title:['待选消缺员', '已选消缺员']
                        ,id:'keyZeng' //定义唯一索引
                    })
                });
            }else{
                $.post("/XiaoQuGuanLi/ChaChuAnSuoKuang",function(c){
                    transfer.render({
                         elem:'#ZeNgJiaChuAnSUo'
                        ,data:c
                        ,width:150 //定义宽度
                        ,height:210 //定义高度
                        ,title:['待选消缺员', '已选消缺员']
                        ,id: 'keyZeng' //定义唯一索引
                        ,value:arrJson
                    })
                })
            };
            //打开穿梭框
            layer.open({
                type:1,
                content:$("#ZeNgJiaChuAnSUo"),//divID
                area:["500px","350px"],
                btn:["确定","取消"],
                title:"添加巡检员 ",
                yes(){
                    //1.穿梭框表单数据
                    let  getData = transfer.getData('keyZeng');
                    //2.表单显示名字数组
                    let arr = new Array();
                    for(let i=0;i<getData.length;i++){
                        arr.push(getData[i].title)
                    }
                    //3.value 值数组
                    arr1 = new Array();
                    for(let i=0;i<getData.length;i++){
                        arr1.push(getData[i].value)
                    }
                    //4.分隔符赋值
                    let  FenGeHou =arr.join(",")
                    $(".xunJiAnYuan").val(FenGeHou);
                    layer.close(layer.index);
                },
                cancel:function(index,layero) {
                    // let getData = transfer.getData('keyZeng');
                    // console.log("getDate"+getData)
                    // //名字数组
                    // for(let i=0;i<getData.length;i++){
                    //
                    //     arr.push(getData[i].title)
                    // }
                    // //value 数组
                    // arr1 = new Array();
                    // for(let i=0;i<getData.length;i++){
                    //     arr1.push(getData[i].value)
                    // }
                    //  FenGeHou =arr.join(",")
                    // $(".xunJiAnYuan").val(FenGeHou);
                    // layer.close(layer.index);
                }
            });
        });
    });

</script>
<!--修改表单-->
<div id="updateDate" style="display:none;"  >
    <form class="layui-form" lay-filter="updateDate" action="" style="padding: 25px;overflow-y:hidden;">
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">任务编码:</label>
            <div class="layui-input-block">
                <input id="RenWUBiAnMa1" type="text" name="solveTaskCode"   lay-verify="required" placeholder="任务编号"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">任务名称:</label>
            <div class="layui-input-block">
                <input id="RenWuMingCheng1"  type="text" name="solveTaskName"   lay-verify="required" placeholder="任务名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px" lay-filter="xunJiAnXianLu">
            <label class="layui-form-label">工作单据:</label>
            <div class="layui-input-inline">
                <select name="workDocTypeName" lay-filter="xnluXiaLa" id="gongzuoDanJu1">
                    <option value="0">请选择</option>
                </select>
            </div>
            <div class="layui-input-inline">
                <button type="button" class="layui-btn layui-btn-normal TianJiaQuXian" id="TianJiaQuXian1" >
                    添加缺陷
                </button>
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px" lay-filter="xunJiAnXianLu">
            <label class="layui-form-label">任务负责人:</label>
            <div class="layui-input-inline">
                <select name="taskManagerName" lay-filter="xnluXiaLa" id="RenWuFuZeRen1">
                    <option value="0">请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">下发人:</label>
            <div class="layui-input-block">
                <input id="addXunJiAnXiaFaRen1" type="text" name="issuedByName" required  lay-verify="required" placeholder="请输入下发人" autocomplete="off" readonly="true"  class="layui-input layui-disabled" th:value="${session.loginUser.userName}">
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">下发日期:</label>
            <div class="layui-input-block">
                <input id="addXiaFaRiQI1" type="text" name="issuedTime" required  lay-verify="required" placeholder="下发人" autocomplete="off" readonly="true"  class="layui-input layui-disabled">
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">任务描述:</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入任务描述" class="layui-textarea" name="taskDesc" id="ReWuMiaoSHu1"></textarea>
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">备注:</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入备注" class="layui-textarea" name="common" id="bz1"></textarea>
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">消缺员:</label>
            <div class="layui-input-block">
                <textarea placeholder="消缺员" class="layui-textarea xunJiAnYuan"  id="xiaoQuYuan1"></textarea>
            </div>
        </div>
    </form>
    <div class="layui-form-item layui-form-text">
        <div class="layui-card">
            <div class="layui-card-body">
                <table id="user-table5" lay-filter="user-table5"></table>
            </div>
        </div>
    </div>
</div>
<!--查看表单-->
<div id="chKan" style="display:none;margin: auto auto" class="aa">
       <h2>查看</h2>
</div>
<!--增加-->
<div id="addmk" style="display:none;"  >
    <form class="layui-form" lay-filter="addform" action="" style="padding: 25px;overflow-y:hidden;">
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">任务编码:</label>
            <div class="layui-input-block">
                <input id="RenWUBiAnMa" type="text" name="solveTaskCode"   lay-verify="required" placeholder="任务编号"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">任务名称:</label>
            <div class="layui-input-block">
                <input id="RenWuMingCheng"  type="text" name="solveTaskName"   lay-verify="required" placeholder="任务名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px" lay-filter="xunJiAnXianLu">
            <label class="layui-form-label">工作单据:</label>
            <div class="layui-input-inline">
                <select name="workDocTypeName" lay-filter="xnluXiaLa" id="gongzuoDanJu">
                    <option value="0">请选择</option>
                </select>
            </div>
            <div class="layui-input-inline">
                <button type="button" class="layui-btn layui-btn-normal TianJiaQuXian" id="TianJiaQuXian">
                     添加缺陷
                </button>
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px" lay-filter="xunJiAnXianLu">
            <label class="layui-form-label">任务负责人:</label>
            <div class="layui-input-inline">
                <select name="taskManagerName" lay-filter="xnluXiaLa" id="RenWuFuZeRen">
                    <option value="0">请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">下发人:</label>
            <div class="layui-input-block">
                <input id="addXunJiAnXiaFaRen" type="text" name="issuedByName" required  lay-verify="required" placeholder="请输入下发人" autocomplete="off" readonly="true"  class="layui-input layui-disabled" th:value="${session.loginUser.userName}">
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">下发日期:</label>
            <div class="layui-input-block">
                <input id="addXiaFaRiQI" type="text" name="issuedTime" required  lay-verify="required" placeholder="下发人" autocomplete="off" readonly="true"  class="layui-input layui-disabled" th:value="${#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd HH:mm:ss')}">
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">任务描述:</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入任务描述" class="layui-textarea" name="taskDesc" id="ReWuMiaoSHu"></textarea>
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">备注:</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入备注" class="layui-textarea" name="common" id="bz"></textarea>
            </div>
        </div>
        <div class="layui-form-item" style="margin-right: 30px">
            <label class="layui-form-label">消缺员:</label>
            <div class="layui-input-block">
                <textarea placeholder="消缺员" class="layui-textarea xunJiAnYuan"  id="xiaoQuYuan"></textarea>
            </div>
        </div>
    </form>
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="user-table3" lay-filter="user-table3"></table>
        </div>
    </div>
</div>
<!--缺陷表格-->
<div id="addmk2" style="display:none;"  >
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="user-table2" lay-filter="user-table2"></table>
        </div>
    </div>
</div>
<!--缺陷表格-->
<!--分配任务id-->
<div id="FenPeiRenWu" class="demo-transfer" style="display:none;margin-left: 65px;margin-top: 35px"></div>
<!--增加巡检任务-->
<div id="ZeNgJiaChuAnSUo" class="demo-transfer" style="display:none;margin-left: 65px;margin-top: 35px"></div>
<!--巡检任务制定分配的查看按钮-->
<div id="Cha" style="display: none" class="layui-form-item">
    <form class="layui-form" id="ChaForm" lay-filter="ChaForm">
        <div class="layui-form-item">
            <input type="hidden" name="id">
            <table cellpadding="0" cellspacing="0" border="1" style="margin-top: 10px">
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">任务编码</td>
                    <td><input type="text" name="solveTaskCode" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">任务名称</td>
                    <td><input type="text" name="solveTaskName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">任务状态</td>
                    <td><input type="text" name="taskStatusName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">工作单据</td>
                    <td><input type="text" name="workDocTypeName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">任务下发人</td>
                    <td><input type="text" name="issuedByName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">任务下发时间</td>
                    <td><input type="text" name="issuedTime" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">任务负责人</td>
                    <td><input type="text" name="taskManagerName" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">任务描述</td>
                    <td><input type="text" name="taskDesc" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 30px;">
                    <td style="width: 180px;" align="center">消缺员</td>
                    <td><input type="text" class="xiaoQuYuan" th:value="${session.loginUser.userName}" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">任务完成时间</td>
                    <td><input type="text" name="finishTime" disabled="disabled" style="border: none;height: 30px;padding-left: 20px"></td>
                </tr>
                <tr style="height: 40px;">
                    <td style="width: 180px;" align="center">负责人审查意见</td>
                    <td><input type="text" name="managerSuggestion" disabled="disabled" style="border: none;height: 40px;padding-left: 20px"></td>
                    <td style="width: 180px;" align="center">完成情况描述</td>
                    <td><textarea placeholder="" disabled="disabled" name="taskFinishDesc" id="taskFinishDesc2" class="layui-textarea" style="min-height:40px;border: none"></textarea></td>
                </tr>
                <tr style="height: 35px;">
                    <td style="width: 180px;" align="center"> 下发人审查意见</td>
                    <td><input type="text" name="issuedSuggestion" disabled="disabled" style="border: none;height: 35px;padding-left: 20px"></td>
                    <!--<td style="width: 180px;" align="center">审核是否通过</td>-->
                    <!--<td><input type="text" name="isCancel"  disabled="disabled" style="border: none;height: 35px;padding-left: 20px"></td>-->
                </tr>
            </table>
        </div>
        <div class="layui-form-item layui-form-text">
            <div class="layui-card">
                <div class="layui-card-body">
                    <table id="user-table4" lay-filter="user-table4"></table>
                </div>
            </div>
         </div>
        <div class="layui-form-item layui-form-text" style="margin-top: 50px">
            <h4 style="margin-left: 100px">工作间断延期记载</h4>
            <div class="layui-input-block">
                <textarea placeholder="无" disabled="disabled" name="taskNotes" id="taskNotes2" class="layui-textarea" style="min-height:60px;border: none"></textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <h4 style="margin-left: 100px">工作终结报告</h4>
            <div class="layui-input-block">
                <textarea placeholder="无" disabled="disabled" name="taskFinishReport" id="taskFinishReport2" class="layui-textarea" style="min-height:60px;border: none"></textarea>
            </div>
        </div>
    </form>
</div>
</body>
</html>